﻿using System;
namespace Producers.Karis.Xtee.Riik.Ee.Producer.Karis {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="krJIsik_id_paring", Namespace="http://producers.karis.xtee.riik.ee/producer/karis", Target=typeof(KrJIsikIdParing))]
    public class KrJIsikIdParingSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IKrJIsikIdParing clazz;
        
        public KrJIsikIdParingSerializer(IKrJIsikIdParing clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("isiku_id");
            if (clazz.IsikuId!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikuId))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikuId");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "isiku_id")) {
                goto isiku_id;
            }
            else {
                return;
            }
        isiku_id:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>krJIsik_id_paring>isiku_id");
            }
            clazz.IsikuId = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isiku_id")).Value;
            goto START;
        }
    }
}
